jQuery.noConflict();
jQuery(function($) {
	let navBarUL = $("#nav-bar");
	let offsettop = navBarUL.get(0).offsetTop;
	$(window).scroll(function() {
		offsettop = navBarUL.get(0).offsetTop;
		let sc = $(this).scrollTop();
		fixedNavBar(sc, navBarUL);
	});

	function fixedNavBar(windowScrollX, obj1, obj2 = "#bonus-bar", posi = "fixed", posiTop = "0px", posiLeft = "0px") {
		if(windowScrollX >= obj1.offset().top) {
			obj1.find(obj2).css({
				"position": posi,
				"top": posiTop,
				"z-index": "9999"

			});
			return;
		}
		obj1.find(obj2).css({
			"position": "",
			"top": "",
			"z-index": ""

		});

	}
	let gamesCouponDiv = $("#games-coupon");
	window.onresize = function() {
		scrollToLeft($("ul#bonus-bar li:lt(3):eq(0)"), 0, gamesCouponDiv);
	}
	$(".fa-align-justify").click(function() {
		scaleLi(1);
	});
	$(".fa-th").click(function() {

		scaleLi(3);
	});
	$(".fa-th-large").click(function() {
		scaleLi(2);

	});

	function scaleLi(scale = 1) {
		gamesCouponDiv.children().children("li").css({
			"width": (100 / scale) + "%"
		});
		console.dir(888);
	}
	$("ul#bonus-bar li:lt(3)").click(function() {
		console.dir($(this).index());
		let _this = $(this);
		scrollToLeft(_this, $(this).index(), gamesCouponDiv);

	});

	function scrollToLeft(obj1, thisIndex, obj2, scale = 1) {
		//let moveLeftUnit = obj2.children().length;
		let offsetleft = -obj2.get(0).children[thisIndex].offsetWidth;
		obj2.css({
			left: (thisIndex * offsetleft) + "px"
		}).children().children("li").css({
			"transform": "scale(" + (scale) + ")"
		});
		obj1.css({
			"border-bottom": "0.1rem solid #0494FD",
			"color": "#0494FD"
		}).siblings().css({
			"border-bottom": "none",
			"color": ""
		});
		console.dir(666);
	}
	$("#backTop01 .fa-angle-double-up").click(function() {
		toTop($("html").get(0).offsetTop);
	});
	$("#backTop01 .fa-angle-double-down").click(function() {
		toTop($("html").get(0).offsetHeight);
	});

	function toTop(destination) {
		try {
			if(destination > -1) {
				$("html").stop(true).animate({
						scrollTop: parseFloat(destination)
					},
					"slow",
					"swing"
				);
			}
		} catch(err) {
			alert(err.message);
		}

	}

});